//
//  CoachsBookUploadImageCell.m
//  CoachsBook
//
//  Created by huiyong li on 2022/8/25.
//

#import "CoachsBookUploadImageCell.h"
@interface CoachsBookUploadImageCell ()
@property (nonatomic, strong) UILabel *titleLabel;

@end
@implementation CoachsBookUploadImageCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier])
    {
        [self WKLSubViews];
        self.contentView.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)WKLSubViews
{

    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(16, 10, 150, 30)];
    self.titleLabel.font = kPingFangRegular(16);
    self.titleLabel.textColor = rgba(51, 51, 51, 1);
    
    
    self.photoImage1 = [[UIImageView alloc]initWithFrame:CGRectMake(16, CGRectGetMaxY(self.titleLabel.frame)+10, APPwidth-32, (APPwidth-32)*200/328)];
    self.photoImage1.backgroundColor = rgba(226, 239, 255, 1);
    self.photoImage1.userInteractionEnabled = YES;
    self.photoImage1.layer.cornerRadius = 8;
    self.photoImage1.layer.masksToBounds = YES;

    
    
    self.cameraBut1 = [[UIButton alloc]initWithFrame:CGRectMake((APPwidth-32-200)/2, (((APPwidth-32)*200/328)-130)/2+10, 200, 130)];
    [self.cameraBut1 setTitle:@"上传照片" forState:UIControlStateNormal];
    [self.cameraBut1 setTitleColor:rgba(22, 120, 255, 1) forState:UIControlStateNormal];
    self.cameraBut1.titleLabel.font = kPingFangRegular(14);;
    [self.cameraBut1 setImage:CoachsBookImageName(@"camera_add") forState:UIControlStateNormal];
    self.cameraBut1.zt_contentAdjustType =ZTContentAdjustImageUpTitleDown;
    [self.cameraBut1 zt_beginAdjustContent];
    [self.photoImage1 addSubview:self.cameraBut1];
    
    
   
    
    
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.photoImage1];
}


-(void)cellFillWithModel:(CoachsBookInputModel *)model
{
    self.titleLabel.text = model.title;
    if (model.showPhotoImage) {
        self.cameraBut1.hidden = YES;
        if ([LongHelper isBlankString:model.photoImageurl]) {
            self.photoImage1.image = model.photoImage;
        }
        else{
            [self.photoImage1 sd_setImageWithURL:[NSURL URLWithString:model.photoImageurl] placeholderImage:zhanweiimage];
        }
    }
    else{
        self.cameraBut1.hidden = NO;
    }

    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
